package com.briup.ch04;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        //动态数据初始化,通过new关键字，在堆中开辟空间，并且有默认值，注意在栈中是没有默认值的
        int[] arr=new int[4];
        System.out.println(arr);
        System.out.println(arr.toString());//Object中的toString
        System.out.println(arr[0]);
        System.out.println(arr[3]);

        //整型数组，里面存放10-20之间的数，一共11个
        int[] arr1=new int[11];
        for (int i = 0; i <arr1.length ; i++) {
            arr1[i]=10+i;
        }
        //现在又叫加入30-40也要放进入
        arr1= Arrays.copyOf(arr1,22);
        System.out.println(arr1.length);
        for (int i = 11; i <arr1.length ; i++) {
            arr1[i]=i+19;
        }
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i]+" ");
        }
        System.out.println();
        System.out.println(arr1);

        //静态初始胡
        int[] arr3=new int[]{1,2,3};
        int[] arr4;
        arr4=new int[]{1,2,3};

        int[] arr5={1,2,3};
        //报错
       /* int[] arr6;
        arr6={1,2,3}*/
    }
}
